<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('model-lolheros', 'Lol Heros');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="lol-heros-index">
    <?php Pjax::begin(); ?>

    <p>
        <?= Html::a(Yii::t('model-lolheros', 'Create Lol Heros'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'name',
            [
                "label" => "英雄",
                "value" => function ($model) { 
                    
                    return $model->title_name . ' - ' . $model->name_cn; 
                }
            ],
            [
                "label" => "职阶",
                "value" => function ($model) { 
                    $tags = explode(',', $model->tags);
                    array_walk($tags, function(&$val){
                        return $val = Yii::t('model-lolheros', $val);
                    });
                    return implode(',  ', $tags); 
                },
            ],
            //'info',
            //'extend:ntext',
            [
                "label" => "头像",
                "format" => [
                    "image", 
                    [
                        "width"=>"84",
                        "height"=>"84"
                    ]
                ],
                "value" => function ($model) { 
                    return $model->img; 
                }
            ],
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
    <?php Pjax::end(); ?>
</div>
